/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 08 - 27
 * Time: 21:22
 */
//牛客 二叉树的最大深度
public class Solution3 {
    //法一 官方推荐方法
    public int maxDepth (TreeNode root) {
        if(root == null) return 0;
        int leftDepth = maxDepth (root.left);
        int rightDepth = maxDepth (root.right);
        return leftDepth > rightDepth ? leftDepth + 1 : rightDepth + 1;
    }
}
